package cuiyt.juc.stream;
import cuiyt.juc.reflaction.User;
import java.util.Arrays;
import java.util.List;
/**
 * @author cyt
 * @create 2020-05-02 0:11
 */
public class demo01 {

    public static void main(String[] args) {
        User user1 = new User(1, "a", 22);
        User user2 = new User(2, "b", 23);
        User user3 = new User(3, "c", 24);
        User user4 = new User(4, "d", 25);
        List<User> userList = Arrays.asList(user1, user2, user3, user4);
        // 使用 stream 流来做计算
        userList.stream()
                .filter((u) -> {
                    return u.getId() % 2 == 0;
                })
                .filter((u) -> {
                    return u.getAge() > 20;
                })
                .map((u) -> {
                    return u.getName().toUpperCase();
                })
                .limit(3)
                .forEach(System.out::println);
    }
}
